package com.itheima.stock.job.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.itheima.stock.common.domain.StockInfoConfig;
import com.itheima.stock.job.service.StockTimerService;

import com.itheima.stock.mapper.*;
import com.itheima.stock.pojo.*;
import com.itheima.stock.utils.IdWorker;
import com.itheima.stock.vo.resp.SecondResVo;
import com.itheima.util.HttpUtils;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Service("stockTimerService")
public class StockTimerServiceImpl implements StockTimerService {

    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private IdWorker idWorker;
    @Autowired
    private StockRtInfoMapper stockRtInfoMapper;
    @Autowired
    private StockMarketIndexInfoMapper stockMarketIndexInfoMapper;
    @Autowired
    private StockBusinessMapper stockBusinessMapper;

    @Autowired
    private StockMarketLogPriceMapper stockMarketLogPriceMapper;
    @Autowired
    private StockBlockRtInfoMapper stockBlockRtInfoMapper;

    @Autowired
    private ThreadPoolTaskExecutor threadPoolTaskExecutor;
    @Autowired
    private StockInfoConfig stockInfoConfig;

    /**
     * 解析定时大盘数据，批量放入数据库
     *
     * @throws ParseException
     */
    @Override
    public void inserdapantBatch() {
        String[] arr={stockInfoConfig.innerszUrl,stockInfoConfig.innerhsUrl};
        String[] arr1={"1010","1011"};
        for (int i=0;i<arr.length;i++) {
            String result = restTemplate.getForObject(arr[i], String.class);
            Map map = JSON.parseObject(result, Map.class);
            Map liston = JSON.parseObject(map.get("result").toString(), Map.class);
            Map lists =(Map)liston.get("lists");
            Map shuju = (Map) lists.get(arr1[i]);
            System.out.println(shuju);


//            StockRtInfo stockRtInfo = new StockRtInfo();
//            stockRtInfo.setId(idWorker.nextId()+"");
//            stockRtInfo.setStockCode(gegu[2]);
//            stockRtInfo.setCurTime(new Date());
//            stockRtInfo.setStockName(gegu[1]);
//            stockRtInfo.setOpenPrice(new BigDecimal(gegu[5]));
//            stockRtInfo.setPreClosePrice(new BigDecimal(gegu[4]));
//            stockRtInfo.setCurPrice(new BigDecimal(gegu[3]));
//            stockRtInfo.setMinPrice(new BigDecimal(gegu[34]));
//            stockRtInfo.setMaxPrice(new BigDecimal(gegu[33]));
//            stockRtInfo.setTradeAmount(gegu[35].split("/")[1]);
//            stockRtInfo.setTradeVolume(new BigDecimal(gegu[35].split("/")[2]));
//            stockRtInfoMapper.insert(stockRtInfo);
//            System.out.println(stockRtInfo.getStockCode()+"插入成功");
        }


    }

    /**
     *
     */
    @Override
    public List<SecondResVo> getStockRtInfoInTime(String code)  {
        //List<String> codeLists=stockRtInfoMapper.getCode();

        //for (int i = 0; i < codeLists.size(); i=1) {

        //发送板块数据请求
        String result = restTemplate.getForObject(stockInfoConfig.getBlockUrl1()+code+".json", String.class);

        Map map = JSON.parseObject(result, Map.class);

        String symbol = map.get("symbol").toString();
        BigDecimal lastVolume = new BigDecimal(map.get("lastVolume").toString());
        String date = map.get("date").toString();
        JSONArray jsonDatas = (JSONArray) map.get("data");
        List<SecondResVo> arrayList = new ArrayList<>();
        for (Object jsonData : jsonDatas) {
            SecondResVo secondResVo = new SecondResVo();
            JSONArray array= (JSONArray) jsonData;
            String time= (String) array.get(0);
            String dateTime=date+time;
            System.out.println("dateTime = " + dateTime);
                /*SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                Date curTime = dateFormat.parse(dateTime);*/
            Date curTime = new DateTime(Long.parseLong( dateTime+ "000")).toDate();
            BigDecimal curPrice = new BigDecimal(array.get(1).toString());
            BigDecimal curCount = new BigDecimal(array.get(2).toString());

            secondResVo.setDate(curTime);
            secondResVo.setTradeAmt(curCount);
            secondResVo.setTradePrice(curPrice);
            secondResVo.setTradeVol(lastVolume);
            arrayList.add(secondResVo);
        }

        return arrayList;
    }

    /**
     * 拉取个股流水数据
     */
    @Override
    public void getStockRtIndex() {
        System.out.println("A股个股代码: " + stockInfoConfig.getStocksList());
        List<String> stocksList = stockInfoConfig.getStocksList();
        List<StockRtInfo> lists = new ArrayList<>();
        Lists.partition(stocksList, 2).forEach( stockList1-> {
            stockList1.forEach(stock -> {
                System.out.println("拉取个股 " + stock + " 的数据信息");
                List<StockRtInfo> rtInfoList = parseStockCodeData(stock);
                System.out.println(rtInfoList);
                lists.addAll(rtInfoList);
            });
           // threadPoolTaskExecutor.execute(() -> {
                stockRtInfoMapper.insertBatch(lists);
                System.out.println("保存到数据库中...");
           // });
        });
    }

    /**
     * 获取A股大盘指数,返回json
     */
    @Override
    public String getInnerMarketInfo() {
        String host = "https://jsszzs.market.alicloudapi.com";
        String path = "/stockindex/sh";
        String method = "GET";
        String appcode = "d47e8d73a72045b8b61a86764d7728ed";
        Map<String, String> headers = new HashMap<String, String>();
        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
        headers.put("Authorization", "APPCODE " + appcode);
        Map<String, String> querys = new HashMap<String, String>();

        try {
            /**
             * 重要提示如下:
             * HttpUtils请从
             * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
             * 下载
             *
             * 相应的依赖请参照
             * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
             */
            HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
            System.out.println(response.toString());
            //获取response的body
            //System.out.println(EntityUtils.toString(response.getEntity()));
            String dapanJson = EntityUtils.toString(response.getEntity());
            //System.out.println(dapanJson);
            return dapanJson;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 拉去国外大盘数据
     *
     * @return
     */
    @Override
    public void gtOuterMarkInfo() {
        List<String> outer = stockInfoConfig.getOuter();
        String url=stockInfoConfig.getOuterUrl();
        ArrayList<String> list1 = new ArrayList<>();
        for (int i = 0; i < outer.size(); i++) {
            String result = restTemplate.getForObject(url+outer.get(i), String.class);
            list1.add(result);
            StockMarketIndexInfo block = parse4StockouterBlock(list1.get(i));
            stockMarketIndexInfoMapper.insert(block);
        }
    }

    private  StockMarketIndexInfo parse4StockouterBlock(String s) {
        String ourcode=s.split("=")[0];
        //ourcode=ourcode.substring(1);
        ourcode=ourcode.substring(2);
        System.out.println(ourcode);
        String s1 = s.split("=")[1];
        String[] split = s1.split("~");
        //数组索引1:纳斯达克100
        //数组索引2:.NDX
        //数组索引3:14009.54
        //数组索引4:-162.20
        //数组索引5:-1.14
        //数组索引6:919414580
        //数组索引7:12880577633630
        StockMarketIndexInfo marketIndexInfo = new StockMarketIndexInfo();
        for (int i = 0; i < split.length; i++) {
            //System.out.println(split);
            marketIndexInfo.setId(idWorker.nextId()+"");
            marketIndexInfo.setMarkId(ourcode);
            marketIndexInfo.setMarkName(split[1]);
            marketIndexInfo.setCurTime(new Date());
            marketIndexInfo.setCurPoint(new BigDecimal(split[3]));
            marketIndexInfo.setCurrentPrice(new BigDecimal(split[3]));
            marketIndexInfo.setUpdownRate(new BigDecimal(split[5]));
            marketIndexInfo.setTradeAccount(split[6]);
            marketIndexInfo.setTradeVolume(split[7]);
        }
        System.out.println("解析大盘数据,插入数据库");
        return marketIndexInfo;
    }

    /**
     * 解析大盘数据，批量放入数据库
     *
     * @throws ParseException
     */
    @Override
    public void insertBatch() throws ParseException {

        Map<String, List> map = parseResultJson();
        List<StockMarketIndexInfo> stockIndexInfoList = map.get("stockIndexInfoList");
        List<StockMarketLogPrice> stockLogList = map.get("stockLogList");
        stockMarketIndexInfoMapper.insertBatch(stockIndexInfoList);
        stockMarketLogPriceMapper.insertBatch(stockLogList);
    }

    @Override
    public void insertRTBatch() throws ParseException {
        List<String> codeList = stockInfoConfig.getStocksList();
      //  List<String> codeList = new ArrayList<>();
 /*       for (int i = 6; i <= 8; i++) {
            List<String> list = parseStockCode(i, 3);
            if (list != null && list.size() > 0) {
                codeList.addAll(list);
            }
        }
        System.out.println("=================");
        System.out.println(codeList)*/;
        //codeList.add("600018");
        ArrayList<StockRtInfo> lists = new ArrayList<>();
        for (String s : codeList) {
            List<StockRtInfo> rtInfoList = parseStockCodeData(s);
            lists.addAll(rtInfoList);
        }

        stockRtInfoMapper.insertBatch(lists);

        System.out.println("插入成功");
    }

    //拉取板块
    @Override
    public void getStockSectorRtIndex() {
        String result = restTemplate.getForObject(stockInfoConfig.getBlockUrl(), String.class);
        //响应结果转板块集合数据
        List<StockBlockRtInfo> infos = parse4StockBlock(result);
        //log.info("板块数据量：{}",infos.size());
        //数据分片保存到数据库下 行业板块类目大概50个，可每小时查询一次即可
        if (infos != null && infos.size() > 0) {
            Lists.partition(infos, 20).forEach(list -> {
                threadPoolTaskExecutor.execute(() -> {
                    //20个一组，批量插入
                    stockBlockRtInfoMapper.insertBatch(list);
                });
            });
        } else {
            System.out.println("未解析出有效板块数据");
        }

    }

    /**
     * 解析板块json
     *
     * @param result
     * @return
     */
    public List<StockBlockRtInfo> parse4StockBlock(String result) {
        List<StockBlockRtInfo> list = new ArrayList<>();
        //System.out.println(result);
        //StockBlockRtInfo stockBlockRtInfo = new StockBlockRtInfo();
        String bkjson = result.split("=")[1];
        Map<String, String> resultMap = new HashMap();
        resultMap = JSON.parseObject(bkjson, Map.class);
        for (Map.Entry<String, String> entry : resultMap.entrySet()) {
            String value = entry.getValue();
            String key = entry.getKey();
            String[] split = value.split(",");
            // System.out.println(key+"："+split.length+"个:"+split);
            StockBlockRtInfo stockBlockRtInfo = new StockBlockRtInfo();
            stockBlockRtInfo.setId(idWorker.nextId() + "");
            stockBlockRtInfo.setLabel(split[0]);
            stockBlockRtInfo.setBlockName(split[1]);
            stockBlockRtInfo.setCompanyNum(Integer.parseInt(split[2]));
            stockBlockRtInfo.setAvgPrice(new BigDecimal(split[3]));
            stockBlockRtInfo.setUpdownRate(new BigDecimal(split[5]));
            stockBlockRtInfo.setTradeAmount(split[6]);
            stockBlockRtInfo.setTradeVolume(new BigDecimal(split[7]));
            stockBlockRtInfo.setCurTime(new Date());
            list.add(stockBlockRtInfo);
            // stockBlockRtInfoMapper.insert(stockBlockRtInfo);
            //System.out.println(stockBlockRtInfo);
            //System.out.println("插入成功");
        }

        return list;
    }

    /**
     * 拉取个股 代码code并解析为list
     *
     * @param pagenum
     * @param pagesize
     * @return
     * @throws ParseException
     */
    @Override
    public List<String> parseStockCode(int pagenum, int pagesize) {
        List<String> codeList = new ArrayList<>();
        String host = "https://jsapigpcx.market.alicloudapi.com";
        String path = "/stock/list";
        String method = "GET";
        String appcode = "d47e8d73a72045b8b61a86764d7728ed";
        Map<String, String> headers = new HashMap<String, String>();
        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
        headers.put("Authorization", "APPCODE " + appcode);
        Map<String, String> querys = new HashMap<String, String>();
        querys.put("classid", "1");
        // 当前页
        querys.put("pagenum", pagenum + "");
        // 每页显示条数
        querys.put("pagesize", pagesize + "");
        try {
            HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
            // System.out.println(response.toString());
            //获取response的body
            String resultJson = EntityUtils.toString(response.getEntity());
            Map map = JSON.parseObject(resultJson, Map.class);
            Map map1 = JSON.parseObject(map.get("result").toString(), Map.class);
            JSONArray jsonArray = (JSONArray) map1.get("list");
            for (Object o : jsonArray) {
                JSONObject jsonObj = (JSONObject) o;
                String name = jsonObj.get("name").toString();
                String code = jsonObj.get("code").toString();
                // System.out.println(name + " : " + code);
                codeList.add(code);
            }
            return codeList;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    /**
     * 拉去个股数据，并解析
     *
     * @param code
     * @return
     */
    @Override
    public List<StockRtInfo> parseStockCodeData(String code) {
        String host = "https://jsapigpcx.market.alicloudapi.com";
        String path = "/stock/query";
        String method = "GET";
        String appcode = "d47e8d73a72045b8b61a86764d7728ed";
        Map<String, String> headers = new HashMap<String, String>();
        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
        headers.put("Authorization", "APPCODE " + appcode);
        Map<String, String> querys = new HashMap<String, String>();
        querys.put("code", code);
        try {
            HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
            System.out.println(response.toString());
            //获取response的body
            //System.out.println(EntityUtils.toString(response.getEntity()));
            String geGuJson = EntityUtils.toString(response.getEntity());
            Map map = JSON.parseObject(geGuJson, Map.class);
            JSONArray jsonArray = (JSONArray) map.get("result");
            List<StockRtInfo> rtInfoList = new ArrayList<>();
            for (Object rt : jsonArray) {
                JSONObject jsonObj = (JSONObject) rt;
                // 股票名称

                String name = jsonObj.get("name").toString();
                System.out.println("--------------" + name + "-------------");
                System.out.println("股票名称 " + name);
                String gpcode = jsonObj.get("code").toString();
                System.out.println("股票代码 " + gpcode);
                 String pp=jsonObj.get("price").toString();
                BigDecimal price = new BigDecimal(pp);
                System.out.println("开盘价 " + price);
                BigDecimal lastclosingprice = new BigDecimal(jsonObj.get("lastclosingprice").toString());
                System.out.println("前收盘价" + lastclosingprice);
                // 当前日期
                // Date updatetime = new DateTime(Long.parseLong(jsonObj.get("updatetime") + "000")).toDate();
                String updatetime = jsonObj.get("updatetime").toString();
                System.out.println("当前时间 " + updatetime);
                JSONArray trendArray = (JSONArray) jsonObj.get("trend");
                System.out.println("数据 " + trendArray);
                double max=Double.parseDouble(pp);
                double min=Double.parseDouble(pp);
                for (Object o : trendArray) {
                    StockRtInfo stockRtInfo = new StockRtInfo();
                    String trend = (String) o;
                    // 处理
                    String[] trendArr = trend.split(",");
                    double ls = Double.parseDouble(trendArr[1]);
                     max = Double.max(max, ls);
                     min=Double.min(min,ls);
                    String curTime = trendArr[0];
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                    Date date = dateFormat.parse(curTime);
                    BigDecimal curPrice = new BigDecimal(trendArr[1]);
                    String tradeAccount = trendArr[2];
                    String tradeVolume = trendArr[3];
                    BigDecimal Volume = new BigDecimal(tradeVolume);
                    stockRtInfo.setId(idWorker.nextId() + "");
                    stockRtInfo.setStockCode(code);
                    stockRtInfo.setCurTime(date);
                    stockRtInfo.setStockName(name);
                    stockRtInfo.setOpenPrice(price);
                    stockRtInfo.setPreClosePrice(lastclosingprice);
                    stockRtInfo.setCurPrice(curPrice);
                    stockRtInfo.setMinPrice(new BigDecimal(min));
                    stockRtInfo.setMaxPrice(new BigDecimal(max));
                    stockRtInfo.setTradeAmount(tradeAccount);
                    stockRtInfo.setTradeVolume(Volume);
                    rtInfoList.add(stockRtInfo);
                    //stockRtInfoMapper.insert(stockRtInfo);
                }

            }
            return rtInfoList;


        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 实时数据
     *
     * @param code
     */
    @Override
    public void getRtcode(String code) {
        String outerUrl = stockInfoConfig.getOuterUrl();
        String[] bm={"sz","sh"};
        String result = restTemplate.getForObject(outerUrl+bm[0]+code, String.class);
        String[] split = result.split("=");
//        for (int i = 0; i < split.length; i++) {
//            System.out.println(split[i]);
//        }
        if (split[0].equals("v_pv_none_match") || split[1].equals("\"1\";")){
            System.out.println("不是sz是sh");
            result = restTemplate.getForObject(outerUrl+bm[1]+code, String.class);
        }else {
            System.out.println("是sz");
           // System.out.println(result);
        }
       // System.out.println(result);
        String[] gegu = result.split("=")[1].split("~");
        StockRtInfo stockRtInfo = new StockRtInfo();
        stockRtInfo.setId(idWorker.nextId()+"");
        stockRtInfo.setStockCode(gegu[2]);
        stockRtInfo.setCurTime(new Date());
        stockRtInfo.setStockName(gegu[1]);
        stockRtInfo.setOpenPrice(new BigDecimal(gegu[5]));
        stockRtInfo.setPreClosePrice(new BigDecimal(gegu[4]));
        stockRtInfo.setCurPrice(new BigDecimal(gegu[3]));
        stockRtInfo.setMinPrice(new BigDecimal(gegu[34]));
        stockRtInfo.setMaxPrice(new BigDecimal(gegu[33]));
        stockRtInfo.setTradeAmount(gegu[35].split("/")[1]);
        stockRtInfo.setTradeVolume(new BigDecimal(gegu[35].split("/")[2]));
        stockRtInfoMapper.insert(stockRtInfo);
        System.out.println(stockRtInfo.getStockCode()+"插入成功");
    }

    /**
     * 批量实时采集个股数据
     */
    @Override
    public void getRtgegubatch() {
        List<String> stocksList = stockInfoConfig.getStockszshcode();
        List<StockBusiness> all = stockBusinessMapper.getAll();
        for (StockBusiness stockBusiness : all) {
            getRtcode(stockBusiness.getSecCode());
        }
    }


    /**
     * 解析大盘数据
     *
     * @return
     * @throws ParseException
     */
    public Map parseResultJson() throws ParseException {
        Map<String, List> resultMap = new HashMap();
        // String dapanJson = JsonConstance.dapanJson;
        String dapanJson = getInnerMarketInfo();
        // 将json字符串转存到Map集合中
        Map map = JSON.parseObject(dapanJson, Map.class);
        // 大盘结果数据
        JSONArray resultJsonArray = (JSONArray) map.get("result");
        // 定义集合用于收集大盘分钟趋势数据
        List<StockMarketIndexInfo> stockIndexInfoList = new ArrayList<>();
        // 定义集合用于收集大盘基础数据 前收盘价 今开盘价
        List<StockMarketLogPrice> stockLogList = new ArrayList<>();
        // 遍历大盘数据数组
        for (Object resultJson : resultJsonArray) {
            // 将获取的元素转成Json对象
            JSONObject jsonObj = (JSONObject) resultJson;
            // 大盘名称
            String name = jsonObj.get("name").toString();
            System.out.println("--------------" + name + "-------------");
            System.out.println("大盘名称 " + name);
            // 大盘代码
            String code = jsonObj.get("code").toString();
            System.out.println("大盘代码 " + code);
            // 处理大盘代码
            if (name.equals("上证指数")) {
                code = "s_sh" + code;
            } else if (name.equals("深证成指")) {
                code = "s_sz" + code;
            } else {
                code = "s_qt" + code;
            }
            // 大盘当前价格
            BigDecimal price = new BigDecimal(jsonObj.get("price").toString());
            System.out.println("大盘当前价格 " + price);
            // 大盘开盘价格
            BigDecimal openningprice = new BigDecimal(jsonObj.get("openningprice").toString());
            System.out.println("大盘开盘 " + openningprice);
            // 收盘价格
            BigDecimal lastclosingprice = new BigDecimal(jsonObj.get("lastclosingprice").toString());
            System.out.println("大盘前收盘价格 " + lastclosingprice);
            // 返回的趋势数据条数
            String trendnum = jsonObj.get("trendnum").toString();
            System.out.println("大盘趋势数据数量 " + trendnum);
            // 当前日期
            Date updatetime = new DateTime(Long.parseLong(jsonObj.get("updatetime") + "000")).toDate();
            System.out.println("当前时间 " + updatetime);
            JSONArray trendArray = (JSONArray) jsonObj.get("trend");
            System.out.println("大盘趋势数据 " + trendArray);
            for (Object o : trendArray) {
                StockMarketIndexInfo stockMarketIndexInfo = new StockMarketIndexInfo();
                // 将每一分钟生成的数据转成字符串
                String trend = (String) o;
                // 处理
                String[] trendArr = trend.split(",");
                String curTime = trendArr[0];
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                Date date = dateFormat.parse(curTime);
                BigDecimal curPrice = new BigDecimal(trendArr[1]);
                String tradeAccount = trendArr[2];
                String tradeVolume = trendArr[3];
                //System.out.println(curTime+" : "+curPrice+" : "+tradeAccount+" : "+tradeVolume);
                stockMarketIndexInfo.setId(idWorker.nextId() + "");
                stockMarketIndexInfo.setMarkId(code);
                stockMarketIndexInfo.setCurTime(date);
                stockMarketIndexInfo.setMarkName(name);
                stockMarketIndexInfo.setCurPoint(curPrice);
                // 当前价格 - 前一日收盘价格
                stockMarketIndexInfo.setCurrentPrice(curPrice.subtract(lastclosingprice)); // 涨跌额
                // (当前价格 - 前一日收盘价格)/前一日收盘价格
                stockMarketIndexInfo.setUpdownRate((curPrice.subtract(lastclosingprice)).divide(lastclosingprice, 4, BigDecimal.ROUND_HALF_UP)); // 涨跌幅
                stockMarketIndexInfo.setTradeAccount(tradeAccount);
                stockMarketIndexInfo.setTradeVolume(tradeVolume);
                stockIndexInfoList.add(stockMarketIndexInfo);
            }
            // 大盘前收盘和今开盘数据
            StockMarketLogPrice stockMarketLogPrice = new StockMarketLogPrice();
            stockMarketLogPrice.setId(idWorker.nextId() + "");
            stockMarketLogPrice.setMarketCode(code);
            stockMarketLogPrice.setCurDate(updatetime);
            stockMarketLogPrice.setPreClosePrice(lastclosingprice);
            stockMarketLogPrice.setOpenPrice(openningprice);
            stockLogList.add(stockMarketLogPrice);
        }
        System.out.println(stockIndexInfoList);
        System.out.println("插入成功...");
        resultMap.put("stockIndexInfoList", stockIndexInfoList);
        resultMap.put("stockLogList", stockLogList);
        return resultMap;
    }
}
